﻿using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using TianShu.Domain.Entities.Auditing;

namespace AutoMapper
{
    public static class IMappingExpressionExtensions
    {
        public static IMappingExpression<TSource, TDestination> IgnorColumn<TSource, TDestination>(this IMappingExpression<TSource, TDestination> mappingExpression) where TDestination : FullAuditedEntity<Guid>
        {
            return mappingExpression.ForMember(e => e.CreationTime, opt => opt.Ignore())
              .ForMember(e => e.CreatorId, opt => opt.Ignore())
              .ForMember(e => e.LastModificationTime, opt => opt.Ignore())
              .ForMember(e => e.LastModifierId, opt => opt.Ignore())
              .ForMember(e => e.DeleterId, opt => opt.Ignore())
              .ForMember(e => e.DeletionTime, opt => opt.Ignore())
              .ForMember(e => e.Id, opt => opt.Ignore())
              .ForMember(e => e.IsDeleted, opt => opt.Ignore());
        }
        public static IMappingExpression<TSource, TDestination> IgnorColumnWithCreationName<TSource, TDestination>(this IMappingExpression<TSource, TDestination> mappingExpression) where TDestination : FullAuditedEntityWithCreationName<Guid>
        {
            return mappingExpression.ForMember(e => e.CreationTime, opt => opt.Ignore())
              .ForMember(e => e.CreatorId, opt => opt.Ignore())
              .ForMember(e => e.LastModificationTime, opt => opt.Ignore())
              .ForMember(e => e.LastModifierId, opt => opt.Ignore())
              .ForMember(e => e.DeleterId, opt => opt.Ignore())
              .ForMember(e => e.DeletionTime, opt => opt.Ignore())
              .ForMember(e => e.CreationName, opt => opt.Ignore())
              .ForMember(e => e.Id, opt => opt.Ignore())
              .ForMember(e => e.IsDeleted, opt => opt.Ignore());
        }
        public static IMappingExpression<TSource, TDestination> IgnorColumnAggregateRoot<TSource, TDestination>(this IMappingExpression<TSource, TDestination> mappingExpression) where TDestination : FullAuditedAggregateRoot<Guid>
        {
            return mappingExpression.ForMember(e => e.CreationTime, opt => opt.Ignore())
              .ForMember(e => e.CreatorId, opt => opt.Ignore())
              .ForMember(e => e.LastModificationTime, opt => opt.Ignore())
              .ForMember(e => e.LastModifierId, opt => opt.Ignore())
              .ForMember(e => e.DeleterId, opt => opt.Ignore())
              .ForMember(e => e.DeletionTime, opt => opt.Ignore())
              .ForMember(e => e.Id, opt => opt.Ignore())
              .ForMember(e => e.IsDeleted, opt => opt.Ignore());
        }
        public static IMappingExpression<TSource, TDestination> IgnorColumnAggregateRootWithCreationName<TSource, TDestination>(this IMappingExpression<TSource, TDestination> mappingExpression) where TDestination : FullAuditedAggregateRootWithCreationName<Guid>
        {
            return mappingExpression.ForMember(e => e.CreationTime, opt => opt.Ignore())
              .ForMember(e => e.CreatorId, opt => opt.Ignore())
              .ForMember(e => e.LastModificationTime, opt => opt.Ignore())
              .ForMember(e => e.LastModifierId, opt => opt.Ignore())
              .ForMember(e => e.DeleterId, opt => opt.Ignore())
              .ForMember(e => e.DeletionTime, opt => opt.Ignore())
              .ForMember(e => e.CreationName, opt => opt.Ignore())
              .ForMember(e => e.Id, opt => opt.Ignore())
              .ForMember(e => e.IsDeleted, opt => opt.Ignore());
        }
        public static IMappingExpression<TSource, TDestination> IgnorProperty<TSource, TDestination, TMember>(this IMappingExpression<TSource, TDestination> mappingExpression, Expression<Func<TDestination, TMember>> destinationMember) 
        {
            return mappingExpression.ForMember(destinationMember, opt => opt.Ignore());
        }
    }
}
